angular.module('starter.controllers', [])
	//晚唐
	.controller('wantangCtrl', function($scope, $ionicSlideBoxDelegate, $stateParams, $ionicScrollDelegate, $state, $ionicPopup, $timeout) {
		$scope.wantangTag = false;
		$scope.tabNames = ['形象', '详解1', '详解2'];
		$scope.slectIndex = 0;
		$scope.activeSlide = function(index) { //点击时候触发
			$scope.slectIndex = index;
			$ionicSlideBoxDelegate.slide(index);
		};
		$scope.slideChanged = function(index) { //滑动时候触发
			$scope.slectIndex = index;
		};
		$scope.getWaixing = function() {
			console.log("bbbbbb");
			$scope.wantangTag = !$scope.wantangTag;
			console.log($scope.wantangTag);
		}

		$scope.showWantangPopup = function() {
			var myPopup = $ionicPopup.show({
				cssClass: 'er-popup',
				templateUrl: 'er_modal_wantang.html',
				scope: $scope
			});
			myPopup.then(function(res) {

			});
			$timeout(function() {
				myPopup.close(); //由于某种原因3秒后关闭弹出
			}, 1000);
		};

		$scope.pages = ["templates/wantang/wantang_tab_03.html", "templates/wantang/wantang_tab_01.html", "templates/wantang/wantang_tab_02.html"];
		$scope.go = function() {
			console.log("hahhahah")
			$state.go('chuzi');
		}
	})
	//盛唐
	.controller('shengtangCtrl', function($scope, $ionicSlideBoxDelegate, $stateParams, $ionicScrollDelegate, $ionicPopup, $timeout) {
		$scope.shengtangTag = false;
		$scope.tabNames = ['形象', '详解1', '详解2'];
		$scope.slectIndex = 0;
		$scope.activeSlide = function(index) { //点击时候触发
			$scope.slectIndex = index;
			$ionicSlideBoxDelegate.slide(index);
		};
		$scope.slideChanged = function(index) { //滑动时候触发
			$scope.slectIndex = index;
		};
		$scope.getPeibo = function() {
			console.log("qqq");
			$scope.peiboTag = !$scope.peiboTag;
			console.log($scope.peiboTag);
		}
		$scope.getBanbi = function() {
			console.log("ccc");
			$scope.banbiTag = !$scope.banbiTag;
			console.log($scope.banbiTag);
		}
		$scope.showShengtangPopup = function() {
			var myPopup = $ionicPopup.show({
				cssClass: 'er-popup',
				templateUrl: 'er_modal_shengtang.html',
				scope: $scope
			});
			myPopup.then(function(res) {

			});
			$timeout(function() {
				myPopup.close(); //由于某种原因3秒后关闭弹出
			}, 1000);
		};
		$scope.pages = ["templates/shengtang/shengtang_tab_03.html", "templates/shengtang/shengtang_tab_01.html", "templates/shengtang/shengtang_tab_02.html", ];
	})
	//初唐
	.controller('chutangCtrl', function($scope, $ionicSlideBoxDelegate, $stateParams, $ionicScrollDelegate, $ionicPopup, $timeout) {
		$scope.chutangTag = false;
		$scope.tabNames = ['形象', '详解1', '详解2'];
		$scope.slectIndex = 0;
		$scope.activeSlide = function(index) { //点击时候触发
			$scope.yifuTag = false;
			$scope.slectIndex = index;
			$ionicSlideBoxDelegate.slide(index);
		};
		$scope.slideChanged = function(index) { //滑动时候触发
			$scope.yifuTag = false;
			$scope.slectIndex = index;
		};
		$scope.showPopup = function(type) {
			console.log(type);
			if(type == "rufu") {
				var myPopup = $ionicPopup.show({
					cssClass: 'er-popup',
					templateUrl: 'er_modal.html',
					scope: $scope
				});
			} else {
				var myPopup = $ionicPopup.show({
					cssClass: 'er-popup',
					templateUrl: 'er_modal2.html',
					scope: $scope
				});
			}

			$scope.getRufu = function(id) {
				console.log(id);
				$scope.imgTianchong = "./img/yifutianchong/" + "rufutianchong_" + id + ".png";
				$scope.yifuTag = true;
				$timeout(function() {
					myPopup.close();
				}, 200);
			};
			$scope.getQunzi = function(id) {
				console.log(id);
				$scope.imgTianchong = "./img/yifutianchong/" + "qunzitianchong_" + id + ".png";
				$scope.yifuTag = true;
				$timeout(function() {
					myPopup.close();
				}, 200);
			};
		};
		$scope.pages = ["templates/chutang/chutang_tab_03.html", "templates/chutang/chutang_tab_01.html", "templates/chutang/chutang_tab_02.html"];
	})

.controller('chuziCtrl', function($scope, $ionicSlideBoxDelegate, $stateParams, $ionicScrollDelegate, $state) {
	$scope.goTopart2 = function() {
		console.log("啊哈哈进来看看才看见爱上");
		$state.go('tab.dash');
	}
	$(function() {
		document.getElementById('ion-side-menu-content').addEventListener('touchend', function(event) {
			console.log($('#ion-side-menu-content').css("transform").substring(12).substring(0, 4));
			setTimeout(function() {
				if($('#ion-side-menu-content').css("transform").substring(12).substring(0, 4) == "-150") {
					$("#fuGai").css({
						"display": "block"
					});
				}
				if($('#ion-side-menu-content').css("transform").substring(12).substring(0, 4) != "-150") {
					$("#fuGai").css({
						"display": "none"
					});
					$("#fuGaiDoor").css({
						"display": "none"
					});
					$("#faxing1").css({
						"display": "none"
					});
					$("#faxing2").css({
						"display": "none"
					});
					$("#faxing3").css({
						"display": "none"
					});
					$("#fashi1").css({
						"display": "none"
					});
					$("#fashi2").css({
						"display": "none"
					});
					$("#fashi3").css({
						"display": "none"
					});
					$("#peishi1").css({
						"display": "none"
					});
					$("#peishi2").css({
						"display": "none"
					});
					$("#peishi3").css({
						"display": "none"
					});
					$("#yifu1").css({
						"display": "none"
					});
					$("#yifu2").css({
						"display": "none"
					});
					$("#yifu3").css({
						"display": "none"
					});

					$("#div_faxing1").css({
						"display": "none"
					});
					$("#div_faxing2").css({
						"display": "none"
					});
					$("#div_faxing3").css({
						"display": "none"
					});
					$("#div_fashi1").css({
						"display": "none"
					});
					$("#div_fashi2").css({
						"display": "none"
					});
					$("#div_fashi3").css({
						"display": "none"
					});
					$("#div_peishi1").css({
						"display": "none"
					});
					$("#div_peishi2").css({
						"display": "none"
					});
					$("#div_peishi3").css({
						"display": "none"
					});
					$("#div_yifu1").css({
						"display": "none"
					});
					$("#div_yifu2").css({
						"display": "none"
					});
					$("#div_yifu3").css({
						"display": "none"
					});
				}
			}, 100);

		}, false);

		$('#door').click(function(e) {
			console.log("hahah！！", e.pageY);

			if($('#fuGaiDoor').css("display") == 'none') {

				if((e.pageY > 470) && (e.pageY < 650)) {
					$("#fuGaiDoor").css({
						"display": "block"
					});
					$("#faxing1").css({
						"display": "block"
					});
					$("#faxing2").css({
						"display": "block"
					});
					$("#faxing3").css({
						"display": "block"
					});
					console.log("发型专区！");
				}
				if((e.pageY > 300) && (e.pageY < 360)) {
					$("#fuGaiDoor").css({
						"display": "block"
					});
					$("#fashi1").css({
						"display": "block"
					});
					$("#fashi2").css({
						"display": "block"
					});
					$("#fashi3").css({
						"display": "block"
					});
					console.log("发饰专区！");
				}
				if((e.pageY > 380) && (e.pageY < 430)) {
					$("#fuGaiDoor").css({
						"display": "block"
					});
					$("#peishi1").css({
						"display": "block"
					});
					$("#peishi2").css({
						"display": "block"
					});
					$("#peishi3").css({
						"display": "block"
					});
					console.log("配饰专区！");
				}
				if((e.pageY > 80) && (e.pageY < 280)) {
					$("#fuGaiDoor").css({
						"display": "block"
					});
					$("#yifu1").css({
						"display": "block"
					});
					$("#yifu2").css({
						"display": "block"
					});
					$("#yifu3").css({
						"display": "block"
					});
					console.log("衣柜专区！");
				}
			}

		})

		$('#fashi1,#fashi2,#fashi3').click(function(e) {

			setTimeout(function() {
				if($('#fuGaiDoor').css("display") == 'block' && $('#fashi1').css("display") == 'block') {

					if((e.pageY > 20) && (e.pageY < 235)) {
						$("#div_fashi1").css({
							"display": "block"
						});
						$("#div_fashi2").css({
							"display": "none"
						});
						$("#div_fashi3").css({
							"display": "none"
						});
					}
					if((e.pageY > 270) && (e.pageY < 480)) {
						$("#div_fashi1").css({
							"display": "none"
						});
						$("#div_fashi2").css({
							"display": "block"
						});
						$("#div_fashi3").css({
							"display": "none"
						});
					}
					if((e.pageY > 500) && (e.pageY < 720)) {
						$("#div_fashi1").css({
							"display": "none"
						});
						$("#div_fashi2").css({
							"display": "none"
						});
						$("#div_fashi3").css({
							"display": "block"
						});
					}
				}
			}, 100);
		})

		$('#faxing1,#faxing2,#faxing3').click(function(e) {

			setTimeout(function() {
				if($('#fuGaiDoor').css("display") == 'block' && $('#faxing1').css("display") == 'block') {

					if((e.pageY > 20) && (e.pageY < 235)) {
						$("#div_faxing1").css({
							"display": "block"
						});
						$("#div_faxing2").css({
							"display": "none"
						});
						$("#div_faxing3").css({
							"display": "none"
						});
					}
					if((e.pageY > 270) && (e.pageY < 480)) {
						$("#div_faxing1").css({
							"display": "none"
						});
						$("#div_faxing2").css({
							"display": "block"
						});
						$("#div_faxing3").css({
							"display": "none"
						});
					}
					if((e.pageY > 500) && (e.pageY < 720)) {
						$("#div_faxing1").css({
							"display": "none"
						});
						$("#div_faxing2").css({
							"display": "none"
						});
						$("#div_faxing3").css({
							"display": "block"
						});
					}
				}
			}, 100);
		})

		$('#peishi1,#peishi2,#peishi3').click(function(e) {

			setTimeout(function() {
				if($('#fuGaiDoor').css("display") == 'block' && $('#peishi1').css("display") == 'block') {

					if((e.pageY > 20) && (e.pageY < 235)) {
						$("#div_peishi1").css({
							"display": "block"
						});
						$("#div_peishi2").css({
							"display": "none"
						});
						$("#div_peishi3").css({
							"display": "none"
						});
					}
					if((e.pageY > 270) && (e.pageY < 480)) {
						$("#div_peishi1").css({
							"display": "none"
						});
						$("#div_peishi2").css({
							"display": "block"
						});
						$("#div_peishi3").css({
							"display": "none"
						});
					}
					if((e.pageY > 500) && (e.pageY < 720)) {
						$("#div_peishi1").css({
							"display": "none"
						});
						$("#div_peishi2").css({
							"display": "none"
						});
						$("#div_peishi3").css({
							"display": "block"
						});
					}
				}
			}, 100);
		})

		$('#yifu1,#yifu2,#yifu3').click(function(e) {

			setTimeout(function() {
				if($('#fuGaiDoor').css("display") == 'block' && $('#yifu1').css("display") == 'block') {

					if((e.pageY > 20) && (e.pageY < 235)) {
						$("#div_yifu1").css({
							"display": "block"
						});
						$("#div_yifu2").css({
							"display": "none"
						});
						$("#div_yifu3").css({
							"display": "none"
						});
					}
					if((e.pageY > 270) && (e.pageY < 480)) {
						$("#div_yifu1").css({
							"display": "none"
						});
						$("#div_yifu2").css({
							"display": "block"
						});
						$("#div_yifu3").css({
							"display": "none"
						});
					}
					if((e.pageY > 500) && (e.pageY < 720)) {
						$("#div_yifu1").css({
							"display": "none"
						});
						$("#div_yifu2").css({
							"display": "none"
						});
						$("#div_yifu3").css({
							"display": "block"
						});
					}
				}
			}, 100);
		})

	})
});